home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / toadebc.zip / EBC2ASC.ASM < prev    next >
Assembly Source File  |  1990-08-13  |  3KB  |  94 lines

  1. ; EBC2ASC.ASM -- Program to convert an EBCDI file to ASCII
  2.  
  3. ; Usage -- EBC2ASC < input filespec > output filespec
  4.  
  5. ; From PC Mag 10-1-85 ASC2EBC.ASM.
  6. ;v1.1    Toad Hall Tweak
  7. ;    Using EBCDIC table from EBCDIC.PAS
  8. ;    David Kirschbaum, Toad Hall
  9. ;    kirsch@usasoc.soc.mil
  10.  
  11. CSEG    Segment
  12.     Assume  CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG
  13.     Org    0100h
  14. Entry:    jmp    Begin
  15.  
  16.  
  17. Table    db    000,001,002,003,    032,009,032,127    ;0..7
  18.     db    032,032,032,011,    012,013,014,015    ;8..0FH
  19.     db    016,017,018,018,    032,032,008,032    ;10H..17H
  20.     db    024,025,032,032,    032,032,032,032    ;18H..1FH
  21.     db    032,032,028,032,    032,010,023,027    ;20H..27H
  22.     db    032,032,032,032,    032,005,006,007    ;28H..2FH
  23.     db    032,032,022,032,    032,030,032,004    ;30H..37H
  24.     db    032,032,032,032,    020,021,032,032    ;38H..3FH
  25.     db    032,032,032,032,    032,032,032,032    ;40H..47H
  26.     db    032,032,155,046,    060,040,043,032    ;48H..4FH
  27.     db    038,032,032,032,    032,032,032,032    ;50H..57H
  28.     db    032,032,033,036,    042,041,059,191    ;58H..5FH
  29.     db    045,047,032,032,    032,032,032,032    ;60H..67H
  30.     db    032,032,124,044,    037,095,062,063    ;68H..6FH
  31.     db    032,032,032,032,    032,032,032,032    ;70H..77H
  32.     db    032,032,058,035,    064,039,061,034    ;78H..7FH
  33.     db    032,097,098,099,    100,101,102,103    ;80H..87H
  34.     db    104,105,032,032,    032,032,032,032    ;88..8FH
  35.     db    032,106,107,108,    109,110,111,112    ;91H..97H
  36.     db    113,114,032,032,    032,032,032,032    ;98H..9FH
  37.     db    032,126,115,116,    117,118,119,120    ;A0H..A7H
  38.     db    121,122,032,032,    032,032,032,032    ;A8H..AFH
  39.     db    032,032,032,032,    032,032,032,032    ;B0H..B7H
  40.     db    032,032,032,032,    032,032,032,032    ;B8H..BFH
  41.     db    123,065,066,067,    068,069,070,071    ;C0H..C7H
  42.     db    072,073,032,032,    032,032,032,032    ;C8H..CFH
  43.     db    125,074,075,076,    077,078,079,080    ;D0H..D7H
  44.     db    081,082,032,032,    032,032,032,032    ;D8H..DFH
  45.     db    092,032,083,084,    085,086,087,088    ;E0H..E7H
  46.     db    089,090,032,032,    032,032,032,032    ;E8H..EFH
  47.     db    048,049,050,051,    052,053,054,055    ;F0H..F7H
  48.     db    056,057,032,032,    032,032,032,032    ;F8H..FFH
  49.  
  50. Begin:    cld                ; Direction Forward
  51.     mov    DX,Offset EndProg    ; Beyone end of program
  52.     mov    CX,SP            ; Top of segment
  53.     sub    CX,100h            ; Leave foom for stack
  54.     sub    CX,DX            ; Number of bytes for buffer
  55.  
  56. MainLoop:
  57.     xor    bx,bx            ; Standard Input        v1.1
  58.     mov    AH,3Fh            ; Read Function Call
  59.     int    21h            ; Call DOS
  60.     jc    Exit            ; Exit if error
  61.  
  62.     push    CX            ; Save requested read bytes
  63.     mov    CX,AX            ; Get bytes read
  64.     jcxz    Exit            ; Exit if no bytes read
  65.  
  66.     mov    BX,Offset Table        ; Conversion Table
  67.     mov    SI,Offset EndProg    ; Beginning of Data
  68.     mov    DI,SI            ; Destination is same
  69.     push    CX            ; Save bytes actually read
  70.  
  71. Conversion:
  72.     lodsb                ; Get byte
  73.     xlat    Table            ; Convert it
  74.     stosb                ; Save byte
  75.     loop    Conversion        ; For all data
  76.  
  77.     pop    CX            ; Get back bytes read
  78.     mov    BX,1            ; Standard Output Handle
  79.     mov    AH,40h            ; Write Function Call
  80.     int    21h            ; Call DOS
  81.     jc    Exit            ; Exit if error
  82.  
  83.     cmp    AX,CX            ; See if all bytes written
  84.     jb    Exit            ; Exit if disk is full
  85.  
  86.     pop    CX            ; Get back bytes to read
  87.     jmp    MainLoop        ; Do next read
  88.  
  89. Exit:    int    20h            ; Terminate Program
  90.  
  91. EndProg    Label    Byte            ; Buffer Area
  92. CSEG    EndS
  93.     End    Entry
  94.